<%- include('../header.html')%>
<style>
    .portlet-title {
        border: 0 !important;
    }

    .img_thumbnailDiv {
        display: inline-block;
    }

    .img_thumbnail {
        width: 150px;
        padding: 5px;
        border: 1px solid #e5e5e5
    }

    #inputFile_sellerImg {
        line-height: 25px;
        opacity: 0;
        margin-left: -160px;
        cursor: pointer;
    }

    .deleteThumb {
        position: relative;
        left: -21px;
        top: -70px;
        padding: 0px 3px;
    }

    #detailEditor .btn-group {
        margin: 5px 5px 5px 0 !important;
    }

    .checkbox input[type="checkbox"] {
        margin-left: 0;
    }
</style>
<div class="page-content">
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <h3 class="page-title">
                </h3>
                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home"></i>
                        <a id="mainModule">基本信息</a>
                        <i class="icon-angle-right"></i>
                    </li>
                </ul>
            </div>
        </div>
        <div id="dashboard">
            <div id="add_edit_container" class="row-fluid">
                <div class="span12">
                    <div class="portlet box blue tabbable">
                        <div class="portlet-title">
                            <h4 class="span10">
                                <i class="icon-reorder"></i>
                                <span class="hidden-480">商家信息</span>
                            </h4>
                        </div>
                        <div class="portlet-body form">
                            <div class="tabbable portlet-tabs">
                                <div class="tab-content">
                                    <div class="tab-pane active" id="portlet_tab1">
                                        <div action="#" class="form-horizontal" style="margin-top: 10px !important;">
                                            <div class="control-group">
                                                <label class="control-label" style="color: #ff0000">商家基本信息：</label>

                                                <div id="flowStateTip" class="controls"
                                                     style="padding-top: 7px;font-size: 14px;color: #ff0000">

                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">公司名称</label>

                                                <div class="controls">
                                                    <input id="companyNameInput" value="<%=seller.Company%>" type="text"
                                                           placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">经营范围</label>

                                                <div class="controls">
                                                    <input id="businessScopeInput" type="text"
                                                           value="<%=seller.BusinessScope%>" placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">公司地址</label>

                                                <div class="controls">
                                                    <input id="companyAddressInput" type="text"
                                                           value="<%=seller.Address%>" placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">公司电话</label>

                                                <div class="controls">
                                                    <input id="companyPhoneInput" type="text" value="<%=seller.Phone%>"
                                                           placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">传真</label>

                                                <div class="controls">
                                                    <input id="faxInput" type="text" value="<%=seller.Fax%>"
                                                           placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">入驻时间</label>

                                                <div class="controls">
                                                    <input id="createTimeInput" type="text"
                                                           value="<%=seller.CreateTime%>" placeholder=""
                                                           class="m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" style="color: #ff0000">退换货信息：</label>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">收件人</label>

                                                <div class="controls">
                                                    <input id="returnUsername" value="<%=seller.ReturnUsername%>"
                                                           type="text" placeholder=""
                                                           class="m-wrap large"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">收件人电话</label>

                                                <div class="controls">
                                                    <input id="returnUserPhone" value="<%=seller.ReturnUserPhone%>"
                                                           type="text" placeholder=""
                                                           class="m-wrap large"/>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label">收件人地址</label>

                                                <div class="controls">
                                                    <input id="returnAddress" value="<%=seller.ReturnAddress%>"
                                                           type="text" placeholder=""
                                                           class="m-wrap large"/>
                                                </div>
                                            </div>


                                            <div class="control-group">
                                                <label class="control-label" style="color: #ff0000">业务联系人信息：</label>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">姓名</label>

                                                <div class="controls">
                                                    <input id="contactorNameInput" type="text"
                                                           value="<%=seller.Contactor%>" placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">电话</label>

                                                <div class="controls">
                                                    <input type="text" value="<%=seller.ContactorPhone%>" placeholder=""
                                                           class="infoInput m-wrap large" disabled="disabled"/>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">其它联系方式</label>

                                                <div class="controls">
                                                    <textarea type="text"
                                                              class="infoInput m-wrap large" disabled="disabled"><%=seller.ContactorDetail%></textarea>
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label" style="color: #ff0000">证照图片：</label>

                                                <div id="certificateTip" class="controls"
                                                     style="padding-top: 7px;font-size: 14px;color: #ff0000">
                                                    请上传合同、营业执照、商标证书、授权书、质检报告扫描件或复印件图片
                                                </div>
                                            </div>
                                            <div class="control-group">
                                                <label class="control-label"> </label>

                                                <div class="controls">
                                                    <div id="thumbContainer">
                                                        <% for(var i=0;i
                                                        <seller.images.length
                                                                ;i++){%>
                                                            <div class="img_thumbnailDiv">
                                                                <img src="<%=seller.images[i]%>" class="img_thumbnail"
                                                                     style="width: 150px;height:150px;display: inline-block">
                                                            </div>
                                                            <%}%>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-actions">
                                                <% if(seller.State=='2'||seller.State=='4'){%>
                                                <button id="btnCheckPass" type="button"
                                                        class="btn blue"><i class="icon-ok"></i>审核通过
                                                </button>
                                                <%}%>
                                                <% if(seller.State=='3'){%>
                                                <button id="btnCheckFail" type="button"
                                                        class="btn red"><i class="icon-remove"></i> 审核不通过
                                                </button>
                                                <%}%>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/javascripts/utils/common.js"></script>
<%- include('../footer.html')%>
<script type="text/javascript" src="../javascripts/utils/layer/layer.js"></script>
<script>
    $("#btnCheckPass").click(function () {
        var returnUsername = $.trim($("#returnUsername").val());
        var returnUserPhone = $.trim($("#returnUserPhone").val());
        var returnUserAddress = $.trim($("#returnAddress").val());
        if (returnUserAddress && returnUsername && returnUserPhone) {
            var sellerObj = {
                State: "3",
                returnUsername: returnUsername,
                returnUserPhone: returnUserPhone,
                returnAddress: returnUserAddress
            };
            sendSeller(sellerObj).done(function (result) {
                if (result) {
                    layer.alert("提交成功！", {closeBtn: false}, function () {
                        window.location.reload();
                    });
                }
            });
        } else {
            layer.alert('请输入退换货信息');
        }


    });

    $("#btnCheckFail").click(function () {
        var sellerObj = {State: "4"};
        sendSeller(sellerObj).done(function (result) {
            if (result) {
                layer.alert("提交成功！", {closeBtn: false}, function () {
                    window.location.reload();
                });
            }
        });
    });

    /**
     * 添加/编辑商家基本信息
     * @param sellerObj
     * @returns {*}
     */
    function sendSeller(sellerObj) {
        var url;
        var sellerId = common.QueryString('id');
        if (sellerId) {
            url = '/seller/audit/' + sellerId;
        }
        $.ajax({
            url: url,
            type: 'POST',
            data: JSON.stringify(sellerObj),
            dataType: 'JSON',
            contentType: 'application/json',
            success: function (res) {
                if (200 === res.code) {
                    console.log(res.data);
                    layer.alert("提交成功！", {closeBtn: false}, function () {
                        window.location.reload();
                    });
                } else {
                    console.log(res.data);
                    layer.alert(res.data);
                }
            },
            error: function (err) {
                layer.alert("与服务器通信发生错误。");
            }
        });
    }
</script>
